<?php

class ControllerInformationTechniques extends Controller {

    public function index() {
        $this->language->load('module/technology');

        $this->data['heading_title'] = $this->language->get('heading_title');

        $this->data['breadcrumbs'] = array();

        $this->data['breadcrumbs'][] = array(
            'text' => $this->language->get('text_home'),
            'href' => $this->url->link('common/home'),
            'separator' => false
        );
          $this->data['breadcrumbs'][] = array(
                        'text' => 'Techniques & Colour',
                        'href' => $this->url->link('information/techniques','' ),
                        'separator' => $this->language->get('text_separator')
                    );
        $this->load->model('tool/image');
        $this->load->model('catalog/technology');
        $this->load->model('catalog/colory');

        $this->data['technologies'] = array();
        $technologies = $this->model_catalog_technology->getTechnologies(0);

        foreach ($technologies as $technology) {
            $children_data = array();

            $children = $this->model_catalog_technology->getTechnologies($technology['technology_id']);

            foreach ($children as $child) {
                $data = array(
                    'filter_technology_id' => $child['technology_id'],
                    'filter_sub_technology' => true
                );


                $children_data[] = array(
                    'technology_id' => $child['technology_id'],
                    'thumb' => $this->model_tool_image->resize($child['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
                    'image' => $this->model_tool_image->resize($child['image'], $this->config->get('config_image_category_width') * 3, $this->config->get('config_image_category_height') * 3),
                    'name' => $child['name'],
                    'description' => html_entity_decode($child['description'], ENT_QUOTES, 'UTF-8'),
                    'href' => $this->url->link('product/technology', 'path=' . $technology['technology_id'] . '_' . $child['technology_id'])
                );
            }

            $data = array(
                'filter_technology_id' => $technology['technology_id'],
                'filter_sub_technology' => true
            );


            $this->data['technologies'][] = array(
                'technology_id' => $technology['technology_id'],
                'name' => $technology['name'],
                'thumb' => $this->model_tool_image->resize($technology['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
                'image' => $this->model_tool_image->resize($technology['image'], $this->config->get('config_image_category_width') * 3, $this->config->get('config_image_category_height') * 3),
                'description' => html_entity_decode($technology['description'], ENT_QUOTES, 'UTF-8'),
                'children' => $children_data,
                'href' => $this->url->link('product/technology', 'path=' . $technology['technology_id'])
            );
        }

        //colory
        $this->data['colories'] = array();
        $colories = $this->model_catalog_colory->getColories(0);

        foreach ($colories as $colory) {
            $children_data = array();

            $children = $this->model_catalog_colory->getColories($colory['colory_id']);

            foreach ($children as $child) {
                $data = array(
                    'filter_colory_id' => $child['colory_id'],
                    'filter_sub_colory' => true
                );


                $children_data[] = array(
                    'colory_id' => $child['colory_id'],
                    'thumb' => $this->model_tool_image->resize($child['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
                    'image' => $this->model_tool_image->resize($child['image'], $this->config->get('config_image_category_width') * 3, $this->config->get('config_image_category_height') * 3),
                    'name' => $child['name'],
                    'description' => html_entity_decode($child['description'], ENT_QUOTES, 'UTF-8'),
                    'href' => $this->url->link('product/colory', 'path=' . $colory['colory_id'] . '_' . $child['colory_id'])
                );
            }

            $data = array(
                'filter_colory_id' => $colory['colory_id'],
                'filter_sub_colory' => true
            );


            $this->data['colories'][] = array(
                'colory_id' => $colory['colory_id'],
                'name' => $colory['name'],
                'thumb' => $this->model_tool_image->resize($colory['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')),
                'image' => $this->model_tool_image->resize($colory['image'], $this->config->get('config_image_category_width') * 3, $this->config->get('config_image_category_height') * 3),
                'description' => html_entity_decode($colory['description'], ENT_QUOTES, 'UTF-8'),
                'children' => $children_data,
                'href' => $this->url->link('product/colory', 'path=' . $colory['colory_id'])
            );
        }






        //// View
        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/techniques.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/information/techniques.tpl';
        } else {
            $this->template = 'default/template/information/techniques.tpl';
        }

        $this->children = array(
            'common/content_maintop',
            'common/column_left',
            'common/column_right',
            'common/content_top',
            'common/content_bottom',
            'common/footer',
            'common/header'
        );

        $this->response->setOutput($this->render());
    }

}

?>